package com.baosight.risk.web.fltd;

import javax.ws.rs.core.MediaType;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baosight.risk.api.fltd.FltdNoticeService;
import com.baosight.risk.base.controller.BaseController;
import com.baosight.risk.common.result.AjaxResult;
import com.baosight.risk.service.fltd.param.FltdNoticeQueryActiveParam;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

/**
 * 作者： lishaoqing
 * 时间： 2019年11月09日
 * 描述： FltdNoticeController
 * 版本: v1.0
 */
@Api(value="xbus待办",description = "xbus待办",produces = MediaType.APPLICATION_JSON)
@Slf4j
@RestController
@RequestMapping("/fltd/notice")
public class FltdNoticeController extends BaseController {

    @Autowired
    private FltdNoticeService fltdNoticeService;

    @ApiOperation("新增oa待办")
    @PostMapping("add")
    public AjaxResult add(@RequestBody String userCode) throws Exception{
        fltdNoticeService.add(userCode);
        return AjaxResult.success();
    }

    @ApiOperation("待办")
    @PostMapping("send")
    public AjaxResult send(@RequestBody String userCode, String userName, int num) throws Exception{
        fltdNoticeService.send(userCode, userName, num);
        return AjaxResult.success();
    }

    @ApiOperation("关闭oa待办")
    @PostMapping("close")
    public AjaxResult close(String userCode) throws Exception{
        fltdNoticeService.closeMessage(userCode);
        return AjaxResult.success();
    }

    @ApiOperation("查询活动待办")
    @GetMapping("queryActivePage")
    public AjaxResult queryActivePage(FltdNoticeQueryActiveParam param) {
    	startPage();
        return getResultPage(fltdNoticeService.queryActiveNotices(param));
    }

    @ApiOperation("删除oa待办")
    @DeleteMapping("deleteOAById")
    public AjaxResult deleteOAById(@RequestParam String id) throws Exception{
        fltdNoticeService.deleteOAById(id);
        return AjaxResult.success();
    }

}
